﻿using System;

namespace Moe.ECamel.Common.Utils
{
	public class FixedClock : IClock
	{
		private DateTime _currentTime;

		public FixedClock()
		{
			this._currentTime = DateTime.Now;
		}

		public DateTime CurrentTime
		{
			get { return _currentTime; }
			set { _currentTime = value;}
		}

		public DateTime Now
		{
			get { return _currentTime; }
		}

		public DateTime Today
		{
			get { return _currentTime.Date; }
		}

		public bool Readonly
		{
			get { return false; }
		}
		public void ChangeCurrentDateTime(DateTime newValue)
		{
			DateTime oldTime = _currentTime;
			_currentTime = newValue;
			if (ClockChanged != null)
				ClockChanged(this, new ClockChangedEventArgs(oldTime, newValue));
		}

		public event EventHandler<ClockChangedEventArgs> ClockChanged;
	}
}
